<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>导购员公众号管理系统登入</title>
    <meta name="description" content="">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="icon" type="image/png" href="__PUBLIC__/assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="__PUBLIC__/assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
    <link rel="stylesheet" href="__PUBLIC__/assets/css/amazeui.min.css"/>
    <link rel="stylesheet" href="__PUBLIC__/assets/css/admin.css">
    <link rel="stylesheet" href="__PUBLIC__/assets/css/app.css">
</head>

<body data-type="login">

<div class="am-g myapp-login" id="login">
    <div class="myapp-login-logo-block  tpl-login-max">
        <div class="myapp-login-logo-text">
            <div class="myapp-login-logo-text">
                导购员公众号管理系统
                <!--<span> 公众号</span>-->
                <!--<i class="am-icon-skyatlas">1</i>-->

            </div>
        </div>

        <!--<div class="login-font">-->
        <!--<i>Log In </i> or <span> Sign Up</span>-->
        <!--</div>-->
        <div class="am-u-sm-10 login-am-center">
            <div class="am-form">
                <fieldset>
                    <div class="am-form-group">
                        <input type="text" class="" placeholder="请输入账号" name="username" id="username">
                    </div>
                    <div class="am-form-group">
                        <input type="password" class="" placeholder="请输入密码" name="password" id="password">
                    </div>
                    <p>
                        <button class="am-btn am-btn-default" @click="submit">登录</button>
                    </p>
                </fieldset>
            </div>
        </div>

        <div class="am-modal am-modal-alert" tabindex="-1" id="login-error">
            <div class="am-modal-dialog">
                <div class="am-modal-hd">登录失败</div>
                <div class="am-modal-bd">
                    {{error_msg}}
                </div>
                <div class="am-modal-footer">
                    <span class="am-modal-btn">确定</span>
                </div>
            </div>
        </div>

    </div>
</div>

<script src="__PUBLIC__/assets/js/jquery.min.js"></script>
<script src="__PUBLIC__/assets/js/amazeui.min.js"></script>
<script src="__PUBLIC__/assets/js/app.js"></script>
<script src="__PUBLIC__/vue.js"></script>

<script>
    var vm = new Vue({
        el: '#login',
        data: {
            error_msg: '登录失败',
        },
        methods: {
            submit: function (event) {
                var username = $('#username')[0].value;
                var password = $('#password')[0].value;
                $.ajax({
                    type: 'post',
                    url: '../Login/login',
                    dataType: 'json',
                    data: {
                        username: username,
                        password: password,
                    },
                    success: function (data) {
                        if (data.stateCode == 205) {
                            $('#login-error').modal();
                            vm.error_msg = data.message;
                        }
                        if (data.stateCode == 200) {
                            window.location = '../Admin/user_manager';
                        }
                    },
                    error: function (data) {
                    }
                })

            }
        }
    });
</script>
</body>

</html>